Skip to content

Comments

Reapply "Unused Variable Warnings" (#1825)#1832

Open
lmulcahy21 wants to merge 15 commits intodevfrom
unused-var-warnings-2
Open

Reapply "Unused Variable Warnings" (#1825)#1832
lmulcahy21 wants to merge 15 commits intodevfrom
unused-var-warnings-2

Conversation

@lmulcahy21
Copy link
Contributor

This reverts commit 2bdb606, reversing changes made to 5328152. See original PR at #1033.

@disconcision disconcision requested a review from Copilot July 30, 2025 20:26
@cyrus- cyrus- requested a review from Copilot July 30, 2025 20:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reapplies functionality for displaying unused variable warnings in the Hazel editor. The feature adds visual indicators and user interface elements to show warnings about unused variables, with a toggle to enable/disable warning display.

Key Changes

  • Adds a warnings system with visual styling to differentiate warnings from errors
  • Implements unused variable detection for pattern variables
  • Adds a user settings toggle to control warning display visibility

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/web/www/style/variables.css Defines warning-specific CSS color variables and z-index values
src/web/www/style/editor.css Adds styling for warning decorations with dashed borders
src/web/www/style/dynamics.css Updates error message selector syntax
src/web/www/style/cursor-inspector.css Styles cursor inspector warning states
src/web/view/NutMenu.re Adds warnings toggle to developer menu
src/web/app/inspector/CursorInspector.re Implements warning display logic in cursor inspector
src/web/app/editors/decoration/Deco.re Adds warning decorations to editor
src/web/app/common/ProjectorView.re Adds warning state to projector status
src/web/Settings.re Adds display_warnings setting
src/language/statics/Warning.re Defines warning types and unused variable detection
src/language/statics/Statics.re Integrates warning detection into static analysis
src/language/statics/Info.re Adds warning field to info types
src/language/statics/CoCtx.re Adds hole detection utility
src/language/CoreSettings.re Adds display_warnings to core settings
src/haz3lcore/derived/CachedStatics.re Tracks warning IDs alongside error IDs

}

.cell-item.cell-result .error-msg {
.cell-item.cell-result .error-msg .warning-msg {
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSS selector is malformed. It should use a comma to separate selectors for both error and warning messages: .cell-item.cell-result .error-msg, .cell-item.cell-result .warning-msg {

Suggested change
.cell-item.cell-result .error-msg .warning-msg {
.cell-item.cell-result .error-msg, .cell-item.cell-result .warning-msg {

Copilot uses AI. Check for mistakes.
let e_co_ctxs =
List.map2(CoCtx.mk(ctx), p_ctxs, List.map(Info.exp_co_ctx, es));
List.map2(
((p_ctx, _ctx)) => CoCtx.mk(p_ctx, p_ctx),
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CoCtx.mk call uses p_ctx for both arguments, but the original code used ctx for the first argument. This change may affect context handling incorrectly.

Suggested change
((p_ctx, _ctx)) => CoCtx.mk(p_ctx, p_ctx),
((p_ctx, _ctx)) => CoCtx.mk(p_ctx, ctx),

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been scrutinizing these changes flagged by Copilot and am confused. Commenting them out makes unused variable warnings appear even when they are used.
Image
But I don't understand why it would make sense to pass in p_ctx for both ctx_before and ctx_after args to CoCtx.mk. Separately, seems weird to zip together the constant ctx with all the p_ctxs only to ignore it later, assuming that isn't needed at all. Finally, while I don't follow why this change makes sense, I'm pretty sure this would mess up the co-ctx calculation for the overall case expression.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 50.81967% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.09%. Comparing base (c5711fb) to head (2c4015e).

Files with missing lines Patch % Lines
src/web/app/editors/decoration/Arms.re 0.00% 7 Missing ⚠️
src/language/statics/Info.re 68.75% 5 Missing ⚠️
src/language/statics/Warning.re 44.44% 5 Missing ⚠️
src/haz3lcore/projectors/ProjectorBase.re 0.00% 2 Missing ⚠️
src/language/statics/StaticsBase.re 50.00% 2 Missing ⚠️
src/web/Settings.re 0.00% 2 Missing ⚠️
src/web/app/common/ProjectorView.re 0.00% 2 Missing ⚠️
src/web/app/editors/code/CodeWithStatics.re 0.00% 2 Missing ⚠️
src/haz3lcore/derived/CachedStatics.re 50.00% 1 Missing ⚠️
src/language/CoreSettings.re 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1832      +/-   ##
==========================================
- Coverage   50.09%   50.09%   -0.01%     
==========================================
  Files         232      233       +1     
  Lines       25567    25617      +50     
==========================================
+ Hits        12807    12832      +25     
- Misses      12760    12785      +25     
Files with missing lines Coverage Δ
src/language/statics/CoCtx.re 54.16% <100.00%> (+1.99%) ⬆️
src/web/view/NutMenu.re 0.00% <ø> (ø)
src/haz3lcore/derived/CachedStatics.re 34.78% <50.00%> (+0.69%) ⬆️
src/language/CoreSettings.re 0.00% <0.00%> (ø)
src/language/statics/Statics.re 86.88% <92.30%> (+<0.01%) ⬆️
src/haz3lcore/projectors/ProjectorBase.re 5.88% <0.00%> (-0.12%) ⬇️
src/language/statics/StaticsBase.re 45.94% <50.00%> (+0.23%) ⬆️
src/web/Settings.re 0.00% <0.00%> (ø)
src/web/app/common/ProjectorView.re 0.00% <0.00%> (ø)
src/web/app/editors/code/CodeWithStatics.re 33.33% <0.00%> (-1.81%) ⬇️
... and 3 more

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dm0n3y
Copy link
Contributor

dm0n3y commented Dec 3, 2025

@cyrus- @disconcision fixed merge conflicts, seems to work as expected

image image image

dm0n3y and others added 2 commits February 13, 2026 12:37
Resolve merge conflicts keeping both warning support and dev features
(targets/sampling, meta-down, line numbers, selected-expanded styles).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dm0n3y
Copy link
Contributor

dm0n3y commented Feb 17, 2026

@cyrus- thoughts here? #1832 (comment)

@dm0n3y
Copy link
Contributor

dm0n3y commented Feb 19, 2026

@cyrus- thoughts here? #1832 (comment)

resolved by fbc97a8

@dm0n3y
Copy link
Contributor

dm0n3y commented Feb 23, 2026

@cyrus- this should be good to go

Copy link
Member

@cyrus- cyrus- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • turn on warnings by default
  • leave a hole at the bottom of the doc slides so unused variables aren't shown
  • add a section to the doc slides describing how unused variables work (underscore prefix, doesn't show up if there is a hole in the scope of the variable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants